﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestBound : MonoBehaviour
{
    public MeshRenderer meshRender;

    private GameObject maxCube;
    private GameObject sizeCube;
    private GameObject minCube;
    private GameObject centerCube;
    private GameObject extentsCube;

    void Start()
    {
        maxCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        sizeCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        minCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        centerCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        extentsCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        
        maxCube.name = "maxCube";
        sizeCube.name = "sizeCube";
        minCube.name = "minCube";
        centerCube.name = "centerCube";
        extentsCube.name = "extentsCube";
        
        maxCube.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        minCube.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        centerCube.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        
        
        
    }

    // Update is called once per frame
    void Update()
    {
        var bounds = meshRender.bounds;
        maxCube.transform.position =  bounds.max;
        minCube.transform.position = bounds.min;
        centerCube.transform.position = bounds.center;
        
        extentsCube.transform.localScale = bounds.extents;
        extentsCube.transform.position = transform.position;
        
        sizeCube.transform.localScale = bounds.size;
        sizeCube.transform.position = transform.position;
        
        
        Debug.Log(meshRender.bounds.size);
    }
}